#include <algorithm>
#include <cstdio>
#include <iostream>
#include <unordered_set>
#include <vector>
using namespace std;

const int kMaxN = 1010;

int n, p;
int num[kMaxN];
vector<int> next_pos[kMaxN];
int sel_num[kMaxN], f[kMaxN];
int depth;

void DFS(int last, int tot) {
  if (tot + f[last] <= depth || !p) {
    return;
  }
  if (tot == depth) {
    p--;
    for (int i = 0; i < tot; i++) {
      printf("%d ", num[sel_num[i]]);
    }
    printf("\n");
    return;
  }

  for (int next : next_pos[last]) {
    sel_num[tot] = next;
    DFS(next, tot + 1);
  }
}

int Pre() {
  for (int i = 0; i < n; i++) {
    unordered_set<int> hash;
    next_pos[i].clear();
    for (int j = i + 1; j < n; j++) {
      if (num[i] <= num[j] && hash.count(num[j]) == 0) {
        hash.insert(num[j]);
        next_pos[i].emplace_back(j);
      }
    }
  }

  int max_f = 0;

  for (int i = n - 1; i >= 0; i--) {
    f[i] = 1;
    for (int j = i + 1; j < n; j++) {
      if (num[i] <= num[j]) {
        f[i] = max(f[i], f[j] + 1);
      }
    }
    max_f = max(max_f, f[i]);
  }
  return max_f;
}

int main() {
  while (scanf("%d%d", &n, &p) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%d", num + i);
    }
    int max_f = min(n - 1, Pre());
    for (depth = 1; p && depth <= max_f; depth++) {
      unordered_set<int> hash;
      for (int i = 0; i < n; i++) {
        if (hash.count(num[i]) == 0) {
          hash.insert(num[i]);
          sel_num[0] = i;
          DFS(i, 1);
        }
      }
    }
    printf("\n");
  }
  return 0;
}